import numpy as np
from define_problem_space_parameters import number_of_time_steps
from  calculate_domain_size import nxp1,ny,nz,nx,nyp1,nzp1
from define_problem_space_parameters import dx,dy,dz,courant_factor
print('initializing FDTD parameters and arrays')

# 常数参数
eps_0 = 8.854187817e-12  # 自由空间介电常数
mu_0 = 4 * np.pi * 1e-7  # 自由空间磁导率
c = 1 / np.sqrt(mu_0 * eps_0)  # 自由空间光速

# 时间步长 (秒)
#dt=5.6706e-12 # 这里使用了固定值，也可以使用CFL条件计算
# dt = 1/(c * np.sqrt((1/dx&zwnj;**2) + (1/dy**&zwnj;2) + (1/dz**2)))
# dt = dx/2/c
# dt = 8.3391e-11
dt = 0.5 * min(dx,min(dy,dz))/c
dt = courant_factor*dt
# 时间数组
time = (np.arange(1, number_of_time_steps + 1) - 0.5) * dt
print('creating field arrays')

# 初始化场量数组
# 注意：nxp1 = nx + 1, nyp1 = ny + 1, nzp1 = nz + 1
Hx = np.zeros((nxp1, ny, nz))
Hy = np.zeros((nx, nyp1, nz))
Hz = np.zeros((nx, ny, nzp1))

Ex = np.zeros((nx, nyp1, nzp1))
Ey = np.zeros((nxp1, ny, nzp1))
Ez = np.zeros((nxp1, nyp1, nz))

E_x = np.zeros((nx, nyp1, nzp1))
E_y = np.zeros((nxp1, ny, nzp1))
E_z = np.zeros((nxp1, nyp1, nz))